{% extends 'home/home.html' %}
{% block index %}
{% load static %}
{% if ispdf %}
<iframe src="{{ real_url }}" width=100% height="88%">
</iframe>
{% else %}
<script type="text/javascript">
    function reinitIframe() {
        var iframe = document.getElementById("true_frame");
        try {
            var bHeight = iframe.contentWindow.document.body.scrollHeight;
            var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
            var height = Math.max(bHeight, dHeight);
            iframe.height = height;
        } catch (ex) { }
    }
    window.setInterval("reinitIframe()", 1000);
</script>
<iframe src="{{ real_url }}" width=100% id="true_frame" frameborder="0" scrolling="no" style="min-height: 90%;">
</iframe>
<!-- 增加base标签，让讲义中的连接在新标签打开 -->
<script>
    var base = document.createElement('base');
    base.target = "_blank";
    document.getElementById('true_frame').onload = function () {
        document.getElementById('true_frame')//获取到iframe
            .contentWindow//获取到iframe的window
            .document//获取到iframe的document
            .getElementsByTagName('head').item(0).appendChild(base);
    };
</script>
{% endif %}
{% endblock %}